import { AxiosRequestConfig } from "axios";
import { ENABLE_REQUEST_LOG } from "./config";
import { message } from 'ant-design-vue'

export function requestLog(config: AxiosRequestConfig): void {
  ENABLE_REQUEST_LOG &&
    console.log(
      `%c
请求地址: ${config.baseURL}${config.url}
请求方法: ${config.method ?.toLocaleUpperCase()}
请求参数: 
${JSON.stringify(
        config.method ?.toLocaleUpperCase() === "GET" ? config.params : config.data,
        null,
        2
      )}
  `,
      "color: #e09628;"
    );
}


export const Message = {
  fail(content: unknown) {
    message.error(content as string);
  }
}